import request from '@/utils/request'

// 获取存款趋势
export function getDepositTrend(startDate, endDate) {
  // 需要格式化日期为 'yyyy-MM-dd' 格式
  const formatDate = (date) => {
    const year = date.getFullYear()
    const month = String(date.getMonth() + 1).padStart(2, '0')
    const day = String(date.getDate()).padStart(2, '0')
    return `${year}-${month}-${day}`
  }

  return request({
    url: '/chart/deposit/trend',
    method: 'get',
    params: {
      startDate: formatDate(startDate),
      endDate: formatDate(endDate)
    }
  })
}

// 获取客户区域分布
export function getCustomerAreaDist(startDate, minAmount = 10000, limit = 10) {
  const formatDate = (date) => {
    const year = date.getFullYear()
    const month = String(date.getMonth() + 1).padStart(2, '0')
    const day = String(date.getDate()).padStart(2, '0')
    return `${year}-${month}-${day}`
  }

  return request({
    url: '/chart/customer/area',
    method: 'get',
    params: {
      startDate: formatDate(startDate),
      minAmount,
      limit
    }
  })
}

